package com.oplink.webbase.modules.cfg.entity;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.oplink.webbase.modules.sys.utils.inf.IDict;

/**
 * Configuration Slot Entity
 * 
 * @author yizhang
 */
@Entity
@Table(name = "cfg_slot")
@DynamicInsert
@DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class CfgSlot implements IDict {

	// ID
	private Long slotid;

	// 机盘号
	private int num;

	// 板卡
	private CfgCard card;

	// 所属网元
	private CfgNe nenode;

	// List<AlarmCurrent> aCurrentlist = Lists.newArrayList();

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getSlotid() {
		return slotid;
	}

	public void setSlotid(Long slotid) {
		this.slotid = slotid;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ne")
	@NotFound(action = NotFoundAction.IGNORE)
	@JsonIgnore
	public CfgNe getNenode() {
		return nenode;
	}

	public void setNenode(CfgNe nenode) {
		this.nenode = nenode;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "card")
	@NotFound(action = NotFoundAction.IGNORE)
	public CfgCard getCard() {
		return card;
	}

	public void setCard(CfgCard card) {
		this.card = card;
	}

	// @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE }, fetch = FetchType.LAZY,
	// mappedBy = "slot")
	// @NotFound(action = NotFoundAction.IGNORE)
	// @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	// public List<AlarmCurrent> getaCurrentlist() {
	// return aCurrentlist;
	// }
	//
	// public void setaCurrentlist(List<AlarmCurrent> aCurrentlist) {
	// this.aCurrentlist = aCurrentlist;
	// }

	public void setLabel(String label) {
	}

	public void setValue(String value) {
	}

	@Transient
	@Override
	public String getLabel() {
		return "" + num;
	}

	@Transient
	@Override
	public String getValue() {
		return "" + slotid;
	}
}
